#!/usr/pkg/bin/bash /usr/local/bin/bash

#
# Google SVN $Id$
#

#/*
# * Copyright (c) 2006-2007 Collaborative Fusion, Inc.  All rights reserved.
# * 
# * Developed by: Collaborative Fusion, Inc.
# *                                                      http://www.collaborativefusion.com
# * 
# * Permission is hereby granted, free of charge, to any person obtaining a copy
# * of this software and associated documentation files (the "Software"), to
# * deal with the Software without restriction, including without limitation the
# * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# * sell copies of the Software, and to permit persons to whom the Software is
# * furnished to do so, subject to the following conditions:
# *   1. Redistributions of source code must retain the above copyright notice,
# *      this list of conditions and the following disclaimers.
# *   2. Redistributions in binary form must reproduce the above copyright
# *      notice, this list of conditions and the following disclaimers in the
# *      documentation and/or other materials provided with the distribution.
# *   3. All advertising materials mentioning features or use of this software
# *      must display the following acknowledgement: This product includes 
# *      software developed by Collaborative Fusion, Inc.
# *   4. Neither the name of Collaborative Fusion, Inc. or any of its employees
# *      may be used to endorse or promote products derived from this Software
# *      without specific prior written permission.
#
# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
# * COLLABORATIVE FUSION, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
# * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# */
#
#/*
#* This code was written under funding by Collaborative Fusion, Inc.
#*/

if [ `ps | grep $$ | egrep -v grep | awk '{print $5}'` != "bash" ]; then
        echo "FUCK ME FREDDY THIS ISN'T BASH I'M OUTTIE";
        exit 1;
fi

_intStepCount=0

trap cleanup 1 2 3 14 15

if [ ! -f "./cf.conf" -a -r "./cf.conf" ]; then
        echo "Cannot find cf.conf in ./ ...bailing out!";
        exit 1;
else
        source ./cf.conf

        if [ $? -ne 0 ]; then
                echo "Reading Config Failed!"
                exit 1;
        fi
fi

echo "Preping shadow RD/MD file system ${HOME_DIR}/${SHADOW_PREFIX} on $PLATFORM for $FQDN ..."; good2go $?

echo -n "Okay to continue? [y/n]"
read answer
if [ "$answer" != "y" ]; then
	exit 1;
fi


# template

# Step X:  Foo
echo "Step ${_intStepCount}: Foo "
# -- foo ; good2go $?


# Step X: SSH Keygen baby!
echo "Step ${_intStepCount}: Generating sshd(8) RSA Keys: "
${KEYGEN} -t rsa1  -f ${HOME_DIR}/${SHADOW_PREFIX}/etc/ssh/ssh_host_key -N '' -C root@$UFQDN; good2go $?
${KEYGEN} -t dsa  -f ${HOME_DIR}/${SHADOW_PREFIX}/etc/ssh/ssh_host_dsa_key -N '' -C root@$UFQDN ; good2go $?
${KEYGEN} -t rsa  -f ${HOME_DIR}/${SHADOW_PREFIX}/etc/ssh/ssh_host_rsa_key -N '' -C root@$UFQDN ; good2go $?

# Step X: Timezone !
echo "Step ${_intStepCount}: Setting Time Zone..."
cp ${DSTDIR}/usr/share/zoneinfo/${TIMEZONE} ${HOME_DIR}/${SHADOW_PREFIX}/etc/localtime ; good2go $?


# Step X: Build Aliases Database
echo "Step ${_intStepCount}: Building Sendmail aliases database..."
#newaliases -bi -C/home/fsimages/sendmail.cf ; good2go $?
echo "Skipping mail alias step for now" ; good2go $?

